﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class StatisticCustomer : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if(!IsPostBack)
        {
            if (Session["admin"] != null)
            {
                load_Customer();
            }
            else
            {
                Response.Redirect("blankAdmin.aspx");
            }
            
        }
    }
    bussiness bus;
    private int count_subcrible = 0;
    private int count_normal = 0;
    private int count_total = 0;

    private void load_Customer()
    {
        bus = new bussiness();
        List<Customer> lstCustomer = bus.getAllCustomer();
        foreach (Customer c in lstCustomer)
        {
            count_total++;
            if (c.Status == "subcrible")
            {
                count_subcrible++;
            }
            if (c.Status == "normal")
            {
                count_normal++;
            }
        }
        lblTotal.Text = count_total.ToString();
        lblNormal.Text = count_normal.ToString();
        lblSubcrible.Text = count_subcrible.ToString();
    }
    private void load_subcribleDetail()
    {
        bus = new bussiness();
        grvCustomerSubcrible.DataSource = bus.getview_SubcribleDetail();
        grvCustomerSubcrible.DataBind();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        load_subcribleDetail();
    }
    protected void grvCustomerSubcrible_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grvCustomerSubcrible.PageIndex = e.NewPageIndex;
        load_subcribleDetail();
    }
}